'''
公司名Mozilla
已有字符MMMooozzziiilllllaaa
算已有字符能组成几个公司名，剩下的字符类型有多少
'''

def getResult(comName,mychars):
    comdict = dict()
    charsdict = dict()
    # 获取公司名字典
    for i in comName:
        if i not in comdict:
            comdict[i]=1
        else:
            comdict[i]+=1
    # 获取已有字符字典
    for j in mychars:
        if j not in charsdict:
            charsdict[j] = 1
        else:
            charsdict[j] += 1
    # ----------------------------
    max_res = 100000
    for c in comdict:
        cur = charsdict[c]/comdict[c]
        if int(cur) < max_res:
            max_res = int(cur)
    rest=0
    # 减去倍数
    for k in charsdict:
        if k in comdict:
            charsdict[k] -= max_res*comdict[k]
    for u in charsdict:
        if charsdict[u]>0:
            rest += 1
    return str(max_res),str(rest)

while True:
    com=input().strip()
    chars=input().strip()
    print(' '.join(getResult(com,chars)))